package cn.sciento.farm.devicemanager.gateway.downlink.service.impl;

import cn.sciento.farm.devicemanager.common.constant.MqttConstant;
import cn.sciento.farm.devicemanager.gateway.downlink.service.MqttCallBackFuture;
import cn.sciento.farm.devicemanager.gateway.model.downlink.AbstractBlockData;
import cn.sciento.farm.devicemanager.gateway.model.uplink.fertilizer.inject.*;
import cn.sciento.farm.devicemanager.gateway.uplink.service.fertilizer.InjectFertilizerDisposeService;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;

@Service
@Order(2)
public class InjectFertilizerDataService implements InjectFertilizerDisposeService {



    @Override
    public void handleStatus(InjectFertilizerStatus status) {

    }

    @Override
    public void handleWorkStatus(InjectFertilizerWorkStatus status) {

    }

    @Override
    public void handleError(InjectFertilizerError error) {

    }

    @Override
    public void handleAck(InjectFertilizerAck ack) {
        MqttCallBackFuture mqttCallBackFuture = MqttCallBackFuture.futurePool.get(
                String.format(
                        MqttConstant.INJECT_FERTILIZER_CONTROL_BLOCK_ID,
                        ack.getEui()
                )
        );
        if (mqttCallBackFuture == null) {
            return;
        }
        AbstractBlockData blockData = mqttCallBackFuture.getAbstractBlockData();
            mqttCallBackFuture.setResponse(ack.getActivate().toString());


    }

    @Override
    public void handleSys(InjectFertilizerSys sys) {

    }

    @Override
    public void handleOnline(String eui, int status) {

    }
}
